package com.yz.controller;

import com.yz.entity.Admin;
import com.yz.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class HelloController {

    @Autowired
    AdminService adminService;
    @RequestMapping("/hello.action")
    public ModelAndView hello(){
        ModelAndView mav = new ModelAndView();
        System.out.println("hello springmvc");

        mav.setViewName("hello.html");
        return mav;
    }

    @RequestMapping("/adminList.action")
    public ModelAndView showAll(){
        ModelAndView mav = new ModelAndView();
        List<Admin> admins = adminService.getAllAdmin();
        mav.addObject("admins",admins);
        mav.setViewName("admin/admin/admin_list.jsp");
        return mav;
    }
}